[comment {-*- tcl -*- doctools manpage}]
[manpage_begin TclJs n 0.1]
[copyright {2006-2011 Jos Decoster <jos.decoster@gmail.com>}]
[copyright {2009-2011 Karl Lehenbauer <karllehenbauer@gmail.com>}]
[moddesc {Tcl extension to execute JavaScript using SpiderMonkey}]
[titledesc {Tcl extension to execute JavaScript using SpiderMonkey}]
[require TclJs 0.1]
[description]

[para] This page describes the Tcl [package TclJs] package. It provides a
Tcl interface to create JavaScript interpreters using Spidermonkey, 
evaluate JavaScript code within them, and extend them by adding new
JavaScirpt commands that work by invoking Tcl commands and returning their
results.
Tcl. The [package TclJs]
package adds the namespace [emph js] to the Tcl interpreter in which it is
loaded.

[section COMMANDS]

[list_begin definitions]

[call [cmd ::js::interp]]

Create a new JavaScript interpreter. The command will return a handle to the
newly generated interpreter. This handle can be used interact with the
JavaScript interpreter.

[call [arg jsInterp] [method eval] [arg script]]

Evaluate the specified JavaScript script in the JavaScript interpreter. 
The result of the evaluated script is returned.

If the JavaScript does not compile or does not execute successfully, a
Tcl error is triggered.

[call [arg jsInterp] [method uceval] [arg script]]

Evaluate the specified UniCode script in the JavaScript interpreter. The result
of the evaluated script is returned.

[call [arg jsInterp] [method function] [arg tclCommand] [arg returnType] [opt [arg jsCommand]]]

Add the specified Tcl command [arg tclCommand] as a function callable from
Javascript that returns an element of type [arg returnType] to the
JavaScript interpreter. If [arg jsCommand] is specified, use this as the
JavaScript function name, otherwise use [arg tclCommand] as the name. 
Valid [arg returnType] values are
[emph boolean], [emph double], [emph int] and [emph string].

If the Tcl code has an uncaught error, tcljs will throw a corresponding
JavaScript exception.

[call [arg jsInterp] [method destroy]]

Destroy the JavaScript interpreter

[call [arg jsInterp] [method callback] [arg script]]

Register [arg script] to be called when the JavaScript interpreter executes its
branch callback.

[list_end]
[keywords JavaScript SpiderMonkey]
[manpage_end]
